#pragma GCC optimize(2)
#include <iostream>
#include <algorithm>
#include <cstring>
#include <string>
#include <map>
#include <vector>

using namespace std;
using LL = long long;

bool check(string s){
    int res = 0;
    for(int i = 1; i <= 6; i ++){
        if(s[i] <= '9' && s[i] >= '0'){
            res *= 10;
            res += s[i] - '0';
        }else{
            return false;
        }
    }

    if(res >= 100000 && res <= 999999){
        return true;
    }else{
        return false;
    }
}

int main(){
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s;

    cin >> s;

    if(s.length() == 8 && s[0] >= 'A' && s[0] <= 'Z' && s[7] >= 'A' && s[7] <= 'Z' && check(s)){
        cout << "Yes";
    }else{
        cout << "No";
    }


    return 0;
}